home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / Clouseau libs / Additions.lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  37.3 KB  |  1,089 lines  |  [TEXT/MPS ]

  1. #########################################################################
  2. #########################################################################
  3. ##                     Copyright © Apple Computer, Inc. 1992-1997
  4. ##                                All rights reserved
  5. #########################################################################
  6. #########################################################################
  7. #    
  8. #    Library:        Additions.lib
  9. #    
  10. #    Version:        2.1.4
  11. #    
  12. #    Description:    Useful Clouseau tasks that don't fit in other libraries.
  13. #    
  14. #    Contains:
  15. #        select_named_item()
  16. #        point_to_sys_icon()
  17. #        headerCoords()
  18. #        ClearViews()
  19. #        ClickViewsBoxes()
  20. #        SetDefaultViews()
  21. #        scrapBook()
  22. #        readScrollingList()
  23. #        offset_list()
  24. #        CenterOfWindowClick()
  25. #        hexStr_to_dec()
  26. #        unexpected_dialog()
  27. #        abort_app()
  28. #        quit_all()
  29. #    
  30. #    History:
  31. #        Date:        By:                Changes:
  32. #        05/15/92    Jason Marsh        Created
  33. #        05/15/92    Jonathan Marsh    Created
  34. #        05/15/92    SBR    Created
  35. #        02/19/94    SBR                Changed
  36. #        09/04/95    SBR                Added this header for Radar 1273927
  37. #                                    Changes to Scrapbook
  38. #        09/27/96    SBR/BRL/MSO        Updated copyright headers
  39. #                                    Use SPEC exception handling method (ExceptionHandling.lib)
  40. #        01/21/97    SBR                Deleted older exception code and comments.
  41. #    
  42. #########################################################################
  43.  
  44. Libraries
  45.     "Clouseau.lib", 
  46.     "ExceptionHandling.lib", 
  47.     "Report.lib", 
  48.     "TargetControl.lib", 
  49.     "VUAid.lib";
  50.  
  51. #########################################################################
  52. #    task            select_named_item(name)
  53. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  54. #    Description:    Selects an item by its name in an open window, checks
  55. #                    with get info
  56. #    Parameters:        name: string - name of icon to open
  57. #    Returns:        true:    if successful
  58. #                    false:    if unsuccessful
  59. #    Examples:        select_named_item('Mouse');
  60. #    Assumptions:    None
  61. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  62. #    History:
  63. #        5/15/93        Jonathan Marsh        Created
  64. #########################################################################
  65. task    select_named_item(name)
  66. begin
  67.     rStatus("select_named_item: " + name, 4);
  68.     type_keys({tabKey, name, 'latch', commandKey, 'i'}); #tab insures we don't rename items
  69.     if not await_presence([window t:(name + ' Info')],3,,,6) begin
  70.         key_eq('w',,6);
  71.         return RIncomplete("select_named_item: Could not find item named: {name}", 4);
  72.     end;
  73.     key_eq('w');
  74.     return true;
  75. end;
  76.  
  77.  
  78. #########################################################################
  79. #    task            point_to_sys_icon(PathName, IconName, WindowName, large)
  80. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  81. #    Description:    Points to and highlights an icon in a window.
  82. #    Parameters:        PathName:the path to the window that contains the icon
  83. #                    IconName: name of icon to point to
  84. #                        if 'header' is passed in as the IconName, the mouse is moved to the window header.
  85. #                    WindowName: the window containing the icon
  86. #                    large: Large icon view or small icon view
  87. #    Returns:        true:    if successful
  88. #                    false:    if unsuccessful
  89. #    Examples:        point_to_icon('Mouse');
  90. #    Assumptions:    Window must be icon view, this will not check to confirm
  91. #                    it, as checking is slow.
  92. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  93. #    History:
  94. #        06/01/92    Jason Marsh        Created
  95. #        09/27/96    BRL/MSO            Added SPEC exception handling
  96. #########################################################################
  97. task    point_to_sys_icon(PathName, IconName, WindowName, large := false)
  98. begin
  99.     RStatus("point_to_sys_icon: " + PathName + ":" + IconName,4);
  100.     
  101.     select_window(WindowName);
  102.     
  103.     _Type({tabKey});                #Make sure renaming doesn't happen
  104.     
  105.     if IconName = 'header' 
  106.         return headerCoords();
  107.     
  108.     try 
  109.         match [window t:$oldWindows];
  110.     catch theError
  111.         ExceptionDispatcher(theError,,{"match 1 in point_to_sys_icon", {PathName, IconName, WindowName, large}});
  112.     
  113.     type_keys({IconName, 'down', commandKey, 'latch', optionKey, UpArrowKey, 'up', commandKey});
  114.  
  115.     try 
  116.         match [window t:?currentWindow o:1 r:?windRect];
  117.     catch theError
  118.         ExceptionDispatcher(theError,,{"match 2 in point_to_sys_icon", {PathName, IconName, WindowName, large}});
  119.         
  120.     if isMember(currentWindow, oldWindows)
  121.         type_keys({'latch', commandKey, DownArrowKey});
  122.     else 
  123.         type_keys({'down', commandKey, 'latch', optionKey, DownArrowKey, 'up', commandKey});
  124.     
  125.     wait(2);
  126.     
  127.     IconLoc:= VUAid("IconLocation", {PathName + ":" + IconName},6);
  128.     if IsUndefined(IconLoc) return RIncomplete("point_to_sys_icon: icon is not present or path is incorrect",4);
  129.     
  130.     if windowName = "Apple Menu Items" IconLoc := replace(IconLoc[1] + 15, 1, IconLoc);
  131.     
  132.     if large             #click on center of first letter of name, then move mouse to center of icon
  133.         move_mouse({{iconLoc[1] + 1 + 15,iconLoc[2] + 39 + 39}, 'click', 'relative', {0, -10}});        
  134.     else 
  135.         move_mouse({{iconLoc[1] + 1 + 20,iconLoc[2] + 39 + 9}, 'click', 'relative', {-10, 0}});    
  136.     
  137.     return true;
  138. end;
  139.  
  140. #########################################################################
  141. #    task            headerCoords()
  142. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  143. #    Description:    Moves mouse to the window title, ready for a pop-up
  144. #                    menu navigation.
  145. #    Parameters:        None
  146. #    Returns:        true
  147. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  148. #    History:
  149. #        06/01/92    Jason Marsh        Created
  150. #        09/27/96    BRL/MSO            Added SPEC exception handling
  151. #########################################################################
  152. task    headerCoords() 
  153. begin
  154.     try 
  155.         match [window o:1 r:?Windrect];
  156.     catch theError
  157.         ExceptionDispatcher(theError,,{"match in headerCoords", {[window o:1], false}});
  158.     x:= (Windrect[3] + Windrect[1]) / 2 ;
  159.     y := Windrect[2] +10;
  160.     
  161.     _Move('a', {x,y});
  162.     return true;
  163. end;
  164.  
  165.  
  166. #########################################################################
  167. #    task            ClearViews(v_level)
  168. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  169. #    Description:    clears all check boxes in Views CDEV.
  170. #    Parameters:        none
  171. #    Returns:        true:    if successful
  172. #                    false:    if unsuccessful
  173. #    Examples:        ClearViews();
  174. #    Assumptions:    None
  175. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  176. #    History:
  177. #        04/12/92    SBR        Created
  178. #        2/15/94        GTK        Updated whichCheckSum checksums.
  179. #                            Changed the checkbox rects to 16 pixels, which
  180. #                            is neccesary for CompareWindowRect to return 
  181. #                            consistent checksums at 1-bit depth. 
  182. #########################################################################
  183. task    ClearViews(v_level:=5)            #clears all checkboxes in the ViewsCP
  184. begin
  185.     BoxLocList:= {{'size', {210,155}}, {'kind',{210,170}}, {'label', {210,185}}, {'date',{210,200}},
  186.         {'version',{210,215}}, {'comments', {210,230}}, {'calculate',{29,215}}, {'disk',{29,230}}, {'snap to grid',{210,100}}};
  187.     
  188.     CurBitDepth := VUAid("GetDepth");
  189.     
  190.     RStatus("Clearing all CheckBoxes in the Views Control Panel",v_level);
  191.  
  192.     NotEnabled := VUAid("CompareWindowRect", {201, 128, 217, 144} ,4);
  193.     if "{NotEnabled}" = WhichCheckSum({'-14440','21544','24544','-16448','28864','unknown'},CurBitDepth)
  194.     move_mouse({{210,155}, 'click'},,4);
  195.     
  196.     Enabled := VUAid("CompareWindowRect", {20, 188, 36, 204}, 4);    
  197.     if "{Enabled}" = WhichCheckSum({'8472','20152','4080','8160','-24448','unknown'},CurBitDepth) 
  198.     move_mouse({{29,215}, 'click'},,4);
  199.         
  200.     for i:= 1 to card BoxLocList
  201.         begin
  202.         Bttn := BoxLocList[i][2];
  203.         WindTopX:= Bttn[1] - 9;
  204.         WindTopY:= Bttn[2] - 27;
  205.         WindBottomX:= WindTopX + 16;
  206.         WindBottomY:= WindTopY + 16;
  207.  
  208.         Enabled := VUAid("CompareWindowRect", {WindTopX, WindTopY, WindBottomX, WindBottomY} ,4);
  209.         if "{Enabled}" = WhichCheckSum({'8472','20152','4080','8160','-24448','unknown'},CurBitDepth) 
  210.             move_mouse({Bttn, 'click'},,4);
  211.  
  212.         end;
  213.     return true;
  214. end;
  215.  
  216. #########################################################################
  217. #    task            ClickViewsBoxes(BoxList, v_level)
  218. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  219. #    Description:    Clicks the boxes determined by BoxList parameter
  220. #    Parameters:        BoxList :  a list of strings each of which can be:
  221. #                        'snap to grid', 'size', 'kind', 'label',
  222. #                        'date', 'version', 'comments', 'calculate'
  223. #                    v_level:    verbosity of log output
  224. #    Returns:        true:    if successful
  225. #                    false:    if unsuccessful
  226. #    Examples:        ClickViewsBoxes({'size', 'version'});
  227. #    Assumptions:    None
  228. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  229. #    History:
  230. #        04/12/92    JDM        Created
  231. #########################################################################
  232. task    ClickViewsBoxes(BoxList:={}, v_level :=  5)            #sets the boxes specified in BoxList
  233. begin
  234.     if not select_window("Views") return false;
  235.     
  236.     if RXStatus(v_level) println "Clicking in Views Boxes ", {BoxList};
  237.     
  238.     MMActionList:={};
  239.     BoxLocList:= {{'size', {210,155}}, {'kind',{210,170}}, {'label', {210,185}}, {'date',{210,200}},
  240.         {'version',{210,215}}, {'comments', {210,230}}, {'calculate',{29,215}}, {'disk',{29,230}}, {'snap to grid',{210,100}}};
  241.     
  242.     
  243.     for    i := 1 to card BoxList
  244.         MMActionList := MMActionList + {assoc(BoxList[i],BoxLocList)} + {'click'};    
  245.     move_mouse(MMActionList,,4);
  246. end;
  247.  
  248.  
  249. #########################################################################
  250. #    task            SetDefaultViews(v_level)
  251. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  252. #    Description:    Sets the views to 'Easy install default'
  253. #    Parameters:        v_level:    verbosity of log output
  254. #    Returns:        Nothing
  255. #    Examples:        SetDefaultViews();
  256. #    Assumptions:    None
  257. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  258. #    History:
  259. #        04/12/92    JDM        Created
  260. #        11/18/93    JDL        Removed statements to close Control Panels
  261. #                            window behind Views control panel; new version
  262. #                            of open_control_panel takes care of closing.
  263. #        02/15/94    GTK        Commented out the "default" check because it's
  264. #                            not working correctly.
  265. #                            Removed "snap to grid" from the ClickViewsBoxes
  266. #                            parm list because it is unchecked by default.
  267. #        09/10/94    SBR        Changed the variable "default" to "defaultVal"
  268. #                            because "default" is now a keyword
  269. #        09/27/96    BRL/MSO    Added SPEC exception handling
  270. #########################################################################
  271. task    SetDefaultViews(v_level := 5)
  272. begin
  273.     if not _MatchBoolean([window t:"Views"]) 
  274.     begin
  275.         if not open_control_panel("Views") 
  276.         return false;
  277.     end;
  278.     else if not select_window("Views") 
  279.         return false;
  280.     
  281.     key_eq('a');
  282.     _Type({"9", returnKey});
  283.     move_mouse({{95,89},'click', {59,188}, 'click', 'wait1'});
  284.     
  285.     if not select_descriptor([menuItem t:"Geneva" m:[popup e:true]]!, 4)
  286.         return RIncomplete("Incomplete: unable to change to requested font", v_level);
  287.             
  288.         ### GTK - The following test has been commented out for now because CompareWindowRect 
  289.         ### always seems to return the same checksum no matter what the state of the checkboxes.
  290.         ### This causes the test to always evaluate to true, thereby returning without setting
  291.         ### the Views window to the default values.
  292. #        defaultVal := VUAid("CompareWindowRect", {1, 43, 255, 236});
  293. #        if "{defaultVal}" = whichCheckSum({ '10240','23552','-31744','-15360','-32264','xxx' })
  294. #            return true;
  295.     
  296.     RStatus("Setting Defaults for Views Control Panel, checksum: {defaultVal}",v_level);
  297.     
  298.     ClearViews(v_level);
  299.     ClickViewsBoxes({'size', 'kind', 'label', 'date'},v_level);
  300.     return true;
  301. end;
  302.  
  303.  
  304. #########################################################################
  305. #    task            scrapBook(actionList)
  306. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  307. #    Description:    Opens, performs actions, and closes Scrapbook.
  308. #    Parameters:        ActionList:    List of actions to perform, including:
  309. #                    menu item names:
  310. #                        "Cut", "Copy", "Paste", "Clear", "Undo", "Close", "Quit", etc.
  311. #                    other actions:
  312. #                        {"launch"}                #select Scrapbook from Apple menu
  313. #                        {"twitch"}                #select Scrapbook from Process menu
  314. #                        {"twitch back"}            #twitch back to the initial app
  315. #                        {"scroll", position}    #scroll to position
  316. #                        {"find", type, startPos, endPos}    #find scrap type,
  317. #                                                #look between startPos and endPos items
  318. #                        {"verify", type}        #verify that current item is of correcttype
  319. #                        {"play"}                #click on the play button
  320. #    Returns:        true if good actionList, false if illegal items encountered
  321. #    Examples:        scrapBook({{"launch"}, {"find","PICT",5,6}, "Cut", "Quit"});
  322. #    Assumptions:    Requires VUAid 2.0
  323. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  324. #    History:
  325. #    04/09/92    Jon Marsh        Created
  326. #    02/15/94    Gary Kratzer    Changed scrapTypeRect rect because it was not
  327. #                                within the bounds of the scrapbook item's type.
  328. #                                Updated scrapTypes checksums.
  329. #    03/30/94    Gary Kratzer    Changed to support Capone Scrapbook.
  330. #    04/12/94    Gary Kratzer    More changes to support Capone Scrapbook.
  331. #    09/04/95    SBR                Formatted according to standards.
  332. #    09/27/96    BRL/MSO            Added SPEC exception handling
  333. #########################################################################
  334. task    scrapBook(actionList:= {})
  335. begin
  336.     currentApp := _Match([application]).t;
  337.     
  338.     SSWVersion := _Gestalt('sysv')[2][2];
  339.         
  340.     SSWVersion := numToStr(SSWVersion, 16);        # Convert from base 16
  341.     if SSWVersion >= '0x750'                    # If System 7.5 or greater
  342.     begin
  343.         scrapTypes := {
  344.                         { "snd ", { 22400,28368,-12224,3040,23188,'xxx' } },
  345.                         { "TEXT", { -29392,1312,-7920,2976,31508,'xxx' } },
  346.                         { "PICT", { 19456,-3344,6768,13696,14164,'xxx' } }
  347.                     };
  348.         scrapTypeRect := {61, 226, 146, 237};
  349.     end;
  350.     else 
  351.     begin
  352.         scrapTypes := {
  353.                         { "snd ", { 11072,15696,15264,3040,23188,'xxx' } },
  354.                         { "TEXT", { 8016,1312,-7920,2976,31508,'xxx' } },
  355.                         { "PICT", { -31792,-29184,6768,13696,14164,'xxx' } }
  356.                     };
  357.         scrapTypeRect := {288, 234, 373, 245};
  358.     end;
  359.  
  360.     for each action in actionList 
  361.     begin
  362.         actionIllegal := false;
  363.         actionPassed := false;
  364.         if typeof(action) = 'list' 
  365.         begin
  366.             if action[1] = "launch" 
  367.             begin
  368.                 select_menuItem("Scrapbook");
  369.                 if await_presence([window o:1 t:"Scrapbook"],,, true)
  370.                 begin
  371.                     RStatus("Launched ScrapBook DA", 4);
  372.                     if SSWVersion >= '0x750'                            # If System 7.5 or greater
  373.                         _Size([window o:1 t:"Scrapbook"], 'wh', {387,277});    # Size same as old Scrapbook
  374.                 end;
  375.                 else 
  376.                     actionPassed:= RError("Failed: Unable to launch ScrapBook DA");
  377.             end;
  378.             else if action[1] = "twitch" 
  379.             begin
  380.                 twitch("Scrapbook");
  381.                 RStatus("Twitched to Scrapbook", 4);
  382.             end;
  383.             else if action[1] = "twitch back" 
  384.             begin
  385.                 twitch(currentApp);
  386.                 RStatus("Twitched to previous app - {currentApp}", 4);
  387.             end;
  388.             else if action[1] = "play" 
  389.             begin
  390.                 if select_descriptor([button t:"Play Sound"])
  391.                     RStatus("Played sound from scrapbook", 4);
  392.                 else 
  393.                     actionPassed:= RError("Failed: Couldn't find Play Sound Button in scrapbook");
  394.             end;
  395.             else if action[1] = "scroll" 
  396.             begin
  397.                 if typeOf(action[2]) = 'integer' 
  398.                 begin
  399.                     requested := action[2];
  400.                     
  401.                     controlWithNoName := _Match ([control t:''], true);
  402.  
  403.                     if controlWithNoName 
  404.                     begin
  405.                         scrollStatus := controlWithNoName.s;
  406.                         if scrollStatus[2] + 1 < requested
  407.                             requested := scrollStatus[2] + 1;
  408.                         if requested < 1
  409.                             requested := 1;
  410.                         
  411.                         _Scroll([scrollBar w:1], 'a', {requested - 1, scrollStatus[2]});
  412.                         
  413.                         scrollStatus := _Match ([control t:''], true).s;
  414.  
  415.                         if scrollStatus[1] + 1 = requested
  416.                             RStatus("Scrolled to item {requested} of scrapbook",4);
  417.                         else 
  418.                             actionPassed:= RError("Failed: Scroll to item {requested} of scrapbook failed");
  419.                     end;
  420.                     else 
  421.                         actionPassed:= RIncomplete("Incomplete: Couldn't find scroll bar in scrapbook");
  422.                 end;
  423.                 else 
  424.                     actionIllegal := true;
  425.             end;
  426.             else if action[1] = "find" 
  427.             begin
  428.                 if typeOf(action[2]) = 'string' 
  429.                 begin
  430.                     requested := action[2];
  431.                     startPosition := action[3];
  432.                     endPosition := action[4];
  433.                     if typeOf(startPosition) <> 'integer' 
  434.                         startPosition := 1;
  435.                     if typeOf(endPosition) <> 'integer' 
  436.                         endPosition := 9999;
  437.                     
  438.                     checkList:= assoc( requested, scrapTypes);
  439.                     if checkList 
  440.                     begin
  441.                         controlWithNoName := _Match ([control t:''], true);
  442.  
  443.                         if controlWithNoName    # new logic 8/30/96
  444.                         begin
  445.                             scrollStatus := controlWithNoName.s;
  446.                             if scrollStatus[2] + 1 < startPosition
  447.                                 startPosition := scrollStatus[2] + 1;
  448.                             if startPosition < 1
  449.                                 startPosition := 1;
  450.                             if scrollStatus[2] + 1 < endPosition
  451.                                 endPosition := scrollStatus[2] + 1;
  452.                             
  453.                             found := false;
  454.                             searchPosition := startPosition;
  455.                             if typeOf(bitDepth) <> 'integer' 
  456.                                 bitDepth := VUAid("GetDepth");
  457.                             
  458.                             while (not found) and (searchPosition <= endPosition) 
  459.                             begin
  460.                                 _Scroll([scrollBar w:1], 'a', {searchPosition - 1, scrollStatus[2]});
  461.  
  462.                                 scrollStatus := _Match ([control t:''], true).s;
  463.  
  464.                                 if scrollStatus[1] + 1 <> searchPosition 
  465.                                 begin
  466.                                     actionPassed:= RIncomplete("Incomplete: Scroll to item {startPosition} of scrapbook failed");
  467.                                     searchPosition := 9999;
  468.                                 end;
  469.                                 else 
  470.                                 begin
  471.                                     expected := whichCheckSum(checkList, bitDepth);
  472.                                     actual := VUAid("CompareWindowRect", scrapTypeRect);
  473.                                     if actual = expected 
  474.                                     begin
  475.                                         found := true;
  476.                                         RStatus("Verified: Found entry of type {requested} at position {searchPosition}", 4);
  477.                                     end;
  478.                                     searchPosition := searchPosition + 1;
  479.                                 end;
  480.                             end;
  481.                             if not found
  482.                                 actionPassed:= RError("Failed: Could not find entry of type {requested} between items {startPosition} and {endPosition}");
  483.                         end;
  484.                         else 
  485.                             actionPassed:= RIncomplete("Incomplete: Couldn't find scroll bar in scrapbook");
  486.                     end;
  487.                     else
  488.                         actionPassed:= RIncomplete("Incomplete: Unknown type for finding - add type {requested} to scrapbook routine.");
  489.                 end;
  490.                 else 
  491.                     actionIllegal := true;
  492.             end;
  493.             else if action[1] = "verify" 
  494.             begin
  495.                 if typeOf(action[2]) = 'string' 
  496.                 begin
  497.                     requested := action[2];
  498.  
  499.                     checkList:= assoc( requested, scrapTypes);
  500.                     if checkList 
  501.                     begin
  502.                         if typeof(bitDepth) <> 'integer'
  503.                             bitDepth := VUAid("GetDepth");
  504.                         expected := whichCheckSum(checkList, bitDepth);
  505.                         actual := VUAid("CompareWindowRect", scrapTypeRect);
  506.                         if actual = expected
  507.                             RStatus("Verified that entry was of type {requested}", 4);
  508.                         else 
  509.                             actionPassed:= RError("Failed: Entry was not of type {requested} - actual: {actual} expected: {expected}");
  510.                     end;
  511.                     else
  512.                         RIncomplete("Incomplete: Unknown type for verification - add type {requested} to scrapbook routine.");
  513.                 end;
  514.                 else 
  515.                     actionIllegal := true;
  516.             end;
  517.             else 
  518.                 actionIllegal:= true;
  519.         end;
  520.         else if typeof(action) = 'string'
  521.             actionIllegal := not select_menuItem(action);
  522.         else 
  523.             actionIllegal := true;
  524.  
  525.         if actionIllegal
  526.             RIncomplete("Incomplete: ScrapBook handler recieved unknown action: {action}");
  527.     end;
  528.     return actionPassed or (not actionIllegal);
  529. end; # scrapbook()
  530.  
  531.  
  532. #########################################################################
  533. #    task            readScrollingList(itemInfoList, listParameterBlock)
  534. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  535. #    Description:    Reads the order of items in a scrolling list using VUAid
  536. #                    to determine item types - ideal for things like the Chooser
  537. #    Parameters:        itemInfoList:    {noItemInfo, item1Info, ... , itemNInfo }
  538. #                        itemNinfo:    { itemName, selectedChecksumList, deselectedChecksumList,
  539. #                                        userItem1 (optional), ... , userItemN (optional) }
  540. #                            Note: noItemInfo should always appear fist in the list,
  541. #                                and contains information about empty list spaces.
  542. #                    listParameterBlock :
  543. #                        {
  544. #                            {itemsAcross, itemsDown},    # Items visible in list
  545. #                            wholeListRect,                # Rect {left, top, right, bottom} of whole list
  546. #                            firstItemRect,                # Rect of first item in list
  547. #                            {horizontalOffset, verticalOffset},
  548. #                                                        # Horizontal, vertical item offset, or
  549. #                                                        #    what to add to firstItemRect to get
  550. #                                                        #    secondItemRect, thirdItemRect, etc.
  551. #                            scrollDownMaxRect            # Rect of the lower portion of scrollbar
  552. #                                                        #    in max downward position - what works best is
  553. #                                                        #    just the scrollthumb
  554. #                            scrollDownMaxChecksums        # Checksum list for scroll down max
  555. #                            scrollDownMaxDisabled        # Checksum list for scroll bar disabled
  556. #                            scrollUpArrowLoc,            # Location of Scroll Up arrow {h,v}
  557. #                            scrollDownArrowLoc,            # Location of Scroll Down arrow
  558. #                            itemNameType                # Name of list items type
  559. #                        };
  560. #    Returns:        list of found items, in format of itemInfoList.
  561. #    Examples:        println readScrollingList(gChooserIconsInfo, gChooserParameterBlock);
  562. #    Assumptions:    None
  563. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  564. #    History:
  565. #    5/21/92        Jon Marsh    Created
  566. #########################################################################
  567. task    readScrollingList(itemInfoList, listParameterBlock) 
  568. begin
  569.     itemCounts := listParameterBlock[1];
  570.     listRect := listParameterBlock[2];
  571.     item1Rect := listParameterBlock[3];
  572.     itemOffset := listParameterBlock[4];
  573.     maxScrollRect := listParameterBlock[5];
  574.     maxScrollChecksums := listParameterBlock[6];
  575.     scrollDisabledChecksums := listParameterBlock[7];
  576.     scrollUpArrowLoc := listParameterBlock[8];
  577.     scrollDownArrowLoc := listParameterBlock[9];
  578.     itemTypeName := listParameterBlock[10];
  579.  
  580.     itemList:= {};
  581.     bitDepth := VUAid("GetDepth");
  582.     grays := VUAid("GetGray");
  583.     noErr:= true;
  584.     currentlySelected:= 0;
  585.     currentItem:= 0;
  586.     scrollDown:= true;
  587.  
  588.     rStatus("Reading scrolling list of {itemTypeName}s", 4);
  589.     move_mouse({ scrollUpArrowLoc, 'down', 'wait3', 'up' });
  590.     
  591.     while scrollDown                             #per scroll position
  592.     begin
  593.         for i:= 1 to itemCounts[2]                 #vertical per view area
  594.         begin
  595.             for j:= 1 to itemCounts[1]             #horizontal per view area
  596.             begin
  597.                 currentItem:= currentItem + 1;
  598.                 #get checksum for area where we expect an item
  599.                 itemRect := {    item1Rect[1] + (j-1)*itemOffset[1],
  600.                                 item1Rect[2] + (i-1)*itemOffset[2],
  601.                                 item1Rect[3] + (j-1)*itemOffset[1],
  602.                                 item1Rect[4] + (i-1)*itemOffset[2] };
  603.                 check := VUAid("CompareWindow32Rect", itemRect);
  604.                 rStatus("Looking for {itemTypeName} in position {currentItem} - ckSum: {check}", 4);
  605.                 
  606.                 found:= false;
  607.                 k:= 1;                                    #k loops through known item types
  608.                 while (not found) and (k <= card itemInfoList) 
  609.                 begin
  610.                                                         #check the checksums for selected items
  611.                     if check = whichCheckSum(itemInfoList[k][2], bitDepth, grays) 
  612.                     begin
  613.                         found:= true;                    #add the found item to our list of current item
  614.                         thisItem:= itemInfoList[k][1];    #remember the name for logging
  615.                         if thisItem <> "none"
  616.                             itemList:= itemList + {itemInfoList[k]};
  617.                     end;
  618.                                                         #check the checksums for de-selected items
  619.                     else if check = whichCheckSum(itemInfoList[k][3], bitDepth, grays) 
  620.                     begin
  621.                         found := true;                    #add the found item to our list of current items
  622.                         thisItem := itemInfoList[k][1];    #remember the name for logging
  623.                         if thisItem <> "none"
  624.                             itemList := itemList + {itemInfoList[k]};
  625.                         if currentlySelected = 0        #Remember which item is selected
  626.                             currentlySelected := card itemList;
  627.                         else 
  628.                             rError("Failed: Multiple {itemTypeName}s selected: {itemTypeName}s {currentlySelected} and {currentItem}");
  629.                     end;
  630.                     
  631.                     k:= k+1;
  632.                 end;
  633.                 if found 
  634.                     rStatus("Found item {thisItem}", 4);
  635.                 else 
  636.                     rError("Failed: Unknown checksum ∂'{check}∂' for {itemTypeName} in position {currentItem}");
  637.             end;
  638.         end;
  639.                                                 #See if we've already scrolled down all the way, or if 
  640.                                                 # the scroll bar is disabled.
  641.         check := VUAid("CompareWindow32Rect", maxScrollRect);
  642.         scrollDown :=    (check <> whichCheckSum(maxScrollChecksums, bitDepth, grays)) and
  643.                         (check <> whichCheckSum(scrollDisabledCheckSums, bitDepth, grays));
  644.                         
  645.                                                 # If the list didn't change visually after
  646.                                                 #    scrolling, we probably have an unknown
  647.                                                 #    checkSum for the scroll bar.
  648.         if scrollDown 
  649.         begin
  650.             check:= VUAid("CompareWindow32Rect", listRect);
  651.             move_mouse({ scrollDownArrowLoc, 'click' });
  652.             if VUAid("CompareWindowRect", listRect) = check
  653.                 scrollDown:= rIncomplete("Attempt to scroll {itemTypeName} list failed - Scroll bar checksum: {check}");
  654.         end;
  655.     end;
  656.     if currentlySelected < 1
  657.         rError("Warning: No recognized {itemTypeName} is currently selected.");
  658.     if card itemList < 1
  659.         rError("Failed: No {itemTypeName}s found");
  660.         
  661.     if rXStatus(4)
  662.         println "List of found {itemTypeName}s: ", itemList;
  663.     return itemList;
  664. end;
  665.  
  666. #########################################################################
  667. #    task            offset_list( a, b, v_level )
  668. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  669. #    Description:    Adds the elements of two lists so one list results. 
  670. #                    Use it to easily add offsets to rectangles and points.
  671. #    Parameters:        a,b:        Lists of integers; each can have 2 or 4 elements.
  672. #                                If they are not the same length the smaller is 
  673. #                                appended to itself
  674. #                    v_level:    verbosity level for log output
  675. #    Returns:        list with 2 or 4 items, each one equals a[n] + b[n]
  676. #    Assumptions:    
  677. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  678. #    History:
  679. #        01/19/93    SBR        Created
  680. #        09/18/94    SBR        Added trace hiding.
  681. #        09/27/96    BRL/MSO    Added SPEC exception handling
  682. #                            Added this header
  683. #########################################################################
  684. task offset_list( a := {}, b := {}, v_level := 5 )
  685. begin
  686.     saveTrace := trace(false);
  687.     
  688.     if card a < card b
  689.         a := a + a;
  690.     else if card a > card b
  691.         b := b + b;
  692.     if card a = 2
  693.     begin
  694.         if v_level > 7
  695.             println "offset_List: a: ",a,"  b: ",b, "  total: ",{ a[1]+b[1], a[2]+b[2] };
  696.         returnValue := { a[1]+b[1], a[2]+b[2] };
  697.         trace(saveTrace);
  698.         return returnValue;
  699.     end;
  700.     else if card a = 4
  701.     begin
  702.         returnValue := { a[1]+b[1], a[2]+b[2], a[3]+b[3], a[4]+b[4] };
  703.         trace(saveTrace);
  704.         return returnValue;
  705.     end;
  706.     else
  707.         RIncomplete("offset_list: lengths of a and b must be 2 or 4",1);
  708.     
  709. end;
  710.  
  711.  
  712.  
  713. #########################################################################
  714. #    task            CenterOfWindowClick()
  715. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  716. #    Description:    Clicks in the center of the top window.
  717. #    Parameters:        
  718. #    Returns:        
  719. #    Assumptions:    
  720. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  721. #    History:
  722. #        09/27/96    BRL/MSO    Added SPEC exception handling
  723. #                            Added this header
  724. #########################################################################
  725. task CenterOfWindowClick()
  726. begin
  727.     try 
  728.         match [window o:1 r:?WindRect];
  729.     catch theError
  730.         ExceptionDispatcher(theError,,{"match in CenterOfWindowClick 1", {[window o:1], true}});
  731.  
  732.     XCoord := (WindRect[3] - WindRect[1])/2;
  733.     YCoord := (WindRect[4] - WindRect[2])/2;
  734.     move_mouse({{XCoord,YCoord}, 'click'});
  735. #    println '    "move_mouse", { ', {XCoord,YCoord}, ', "click"},';
  736.  
  737.     try 
  738.         match [window o:1 r:?NewRect];    #In case an about dialog needs multiple clicks to make it go away
  739.     catch theError
  740.         ExceptionDispatcher(theError,,{"match in CenterOfWindowClick 2", {[window o:1], true}});
  741.  
  742.     if NewRect = WindRect 
  743.         CenterOfWindowClick();
  744. end;
  745.  
  746.  
  747. #########################################################################
  748. #    task            hexStr_to_dec(hexValue)
  749. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  750. #    Description:    Converts a hex string between '0000'-'7fff' to an 
  751. #                    integer between 0-32767.
  752. #    Parameters:        
  753. #    Returns:        
  754. #    Assumptions:    
  755. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  756. #    History:
  757. #        09/27/96    BRL        Added this header
  758. #########################################################################
  759. task hexStr_to_dec(hexValue := '0000')
  760.  begin    
  761.     hexits := {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
  762.     decValue := 0;
  763.     hexPlaces := {4096,256,16,1};
  764.     for i := card hexValue to 1 step -1 
  765.     begin
  766.         temp := (hexPlaces[i] * (ismember(hexValue[i], hexits) - 1));
  767.         decValue := decValue + temp;
  768.     end;
  769.     return decValue;
  770. end;
  771.  
  772.  
  773. #########################################################################
  774. #    task            dec_to_hexStr(decValue)
  775. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  776. #    Description:    Converts an integer between 0-32767 to a hex string 
  777. #                    between '0000'-'7fff'.
  778. #    Parameters:        
  779. #    Returns:        
  780. #    Assumptions:    
  781. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  782. #    History:
  783. #        09/27/96    BRL/MSO    Added SPEC exception handling
  784. #                    Added this header
  785. #########################################################################
  786. #    task dec_to_hexStr(decValue := 0)
  787. #    begin    
  788. #        hexits := '0123456789ABCDEF';
  789. #        hexPlaces := {4096,256,16,1};
  790. #        hexValue := '';
  791. #        for i := 1 to card hexPlaces begin
  792. #            temp := decValue / hexPlaces[i];
  793. #            hexValue := hexValue + hexits[temp + 1];
  794. #            decValue := decValue - temp * hexPlaces[i];
  795. #        end;
  796. #        return hexValue;
  797. #    end;
  798.  
  799.  
  800.  
  801.  
  802. #########################################################################
  803. #    task            dec_to_hexStr(decValue)
  804. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  805. #    Description:    Converts a long integer to a hex string between 
  806. #                    '0'-'FFFFFFFF' without the '0x'. 
  807. #    Parameters:        
  808. #    Returns:        
  809. #    Assumptions:    
  810. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  811. #    History:
  812. #        09/27/96    BRL/MSO    Added SPEC exception handling
  813. #                            Added this header
  814. #########################################################################
  815. task dec_to_hexStr(decValue := 0)
  816. begin    
  817.     hexValue := numToStr(decValue);
  818.     
  819.     hexString := '';
  820.     for i := 3 to card hexValue
  821.     begin
  822.         hexString := hexString + hexValue[i];
  823.     end;
  824.     return hexString;
  825. end;
  826.  
  827.  
  828.  
  829. #########################################################################
  830. #    task            unexpected_dialog(expectedItem, expectedDesc, v_level)
  831. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  832. #    Description:    Tries to dismiss unexpected dialogs in standard ways.
  833. #    Parameters:        
  834. #    Returns:        
  835. #    Assumptions:    
  836. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  837. #    History:
  838. #        09/27/96    BRL/MSO    Added SPEC exception handling
  839. #                            Added this header
  840. #########################################################################
  841. task unexpected_dialog(expectedItem := "", expectedDesc := {[]}, v_level := 4)
  842. begin
  843.     try 
  844.         match [target t:?tName];
  845.     catch theError
  846.         ExceptionDispatcher(theError,,{"match 1 in unexpected_dialog", {expectedItem, expectedDesc, v_level}});
  847.     
  848.     if expectedItem = "desc"    #a dialog box may be the expected!
  849.         if _MatchBoolean(expectedDesc[1])
  850.             return false;
  851.             
  852.     try 
  853.         match [window s:?windStyle o:1 k:?kList r:?windRect]!;
  854.     catch theError
  855.         ExceptionDispatcher(theError,,{"match 2 in unexpected_dialog", {expectedItem, expectedDesc, v_level}});
  856.     
  857.     if not isMember(windStyle, {dialog, moveablemodal}) #no dialog
  858.         return false;
  859.     
  860.     topWind := [window s:windStyle k:kList r:windRect];
  861.     
  862.     (*Collect the staticText items*)
  863.     staticList := kList;
  864.     
  865.     for i := card staticList to 1 step -1
  866.     begin
  867.         if (descType(staticList[i]) <> 'staticText')
  868.             staticList := remove(i, staticList);
  869.     end;
  870.     
  871.     if card staticList = 1 
  872.         temp := staticList[1].t;
  873.     else if card staticList = 0 
  874.         temp := "no staticText strings present";
  875.     else 
  876.         temp := "multiple staticText strings, one is: " + staticList[1].t;
  877.     RStatus("unexpected_dialog: {temp}", v_level);
  878.  
  879.     (*Try the escape key*)
  880.     type_keys({escapeKey});
  881.     RStatus("unexpected_dialog: pressed the escape key", v_level);
  882.     if await_absence(topWind,2,,,6)
  883.         return true;
  884.  
  885.     (*Put button titles into a list*)
  886.     buttonList := {};
  887.     for i := 1 to card kList
  888.     begin
  889.         thisContentItem := kList[i];
  890.         if thisContentItem.e and (descType(thisContentItem) = 'button')
  891.             buttonList := buttonList + {thisContentItem.t};
  892.     end;
  893.  
  894.     (*If there is just one enabled button, select it*)
  895.     if (card buttonList = 1)
  896.     begin
  897.         temp := buttonList[1];
  898.         if not (temp ~= /≈launch≈/) 
  899.         begin
  900.             _Select([button t:temp w:1], true);
  901.             RStatus("unexpected_dialog: selected only enabled button {temp}", v_level);
  902.         end;
  903.     end;
  904.     if await_absence(topWind,2,,,6)
  905.         return true;
  906.     
  907.     (*If there are no enabled buttons, signal a warning*)
  908.     else if (card buttonList < 1)
  909.     begin
  910.         CenterOfWindowClick();
  911.         RStatus("unexpected_dialog: clicked in the center of the window", v_level);
  912.         if await_absence(topWind,2,,,6)
  913.             return true;
  914.         else 
  915.         begin
  916.             RStatus("unexpected_dialog: no way out -- need human intervention", v_level);
  917.             RStatus("{tName} IS STUCK IN A DIALOG! PLEASE DISMISS IT TO CONTINUE THE SCRIPT…",1);
  918.             while not await_absence(topWind,60,,,6)
  919.                 SysBeep();
  920.             return true;
  921.         end;
  922.     end;
  923.     else for each goodTry in {'Cancel','Done','OK','No','Yes'}
  924.     begin
  925.         if isMember(goodTry, buttonList) 
  926.         begin
  927.             _Select([button t:goodTry w:1], true);
  928.             RStatus("unexpected_dialog: selected button named {goodTry}", v_level);
  929.             if await_absence(topWind,2,,,6)
  930.                 return true;
  931.         end;
  932.     end;
  933.     RStatus("unexpected_dialog: {buttonList}", v_level);
  934.     for i :=  1 to card buttonList
  935.     begin
  936.         if buttonList[i].t <> ''
  937.         begin
  938.             if _MatchBoolean(buttonList[i])
  939.             begin
  940.                 temp := buttonList[i].t;
  941.                 _Select([button t:temp]);
  942.                 if _MatchBoolean([window s:dialog o:1]) or _MatchBoolean([window s:movablemodal o:1])
  943.                     unexpected_dialog(,,v_level);
  944.             end;
  945.             if not (_MatchBoolean([window s:dialog o:1]) or _MatchBoolean([window s:movablemodal o:1]))
  946.                 i := card buttonList;
  947.         end;
  948.     end;
  949. end;
  950.  
  951. #########################################################################
  952. #    task            abort_app(v_level)
  953. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  954. #    Description:    Guarantees when done that the app is not active or in the process menu. 
  955. #    Parameters:        v_level:        verbosity level for log output
  956. #    Returns:        nothing (will not return until successful)
  957. #    Assumptions:    VU 2.0.1
  958. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  959. #    History:
  960. #        07/25/90    Alan Liu        Creation as part of ApplicationLib.vu for 007
  961. #        03/04/92     Jason Marsh        Incorporation into Clouseau.Lib.
  962. #        03/20/93    SBR        Redesigned for use with Launchquits.lib
  963. #        08/06/93    SBR        Changed to match[target] which forces target access
  964. #        02/19/94    SBR        Moved to Clouseau.lib from Launchquits.lib
  965. #        09/27/96    BRL/MSO    Added SPEC exception handling
  966. #########################################################################
  967. task abort_app(v_level := 4)
  968. begin
  969.     AddExceptionHandler(-1105, { task EH_CrashRecover, {'',2,15}});
  970.     theTarget := _Match([target]);
  971.     RemoveExceptionHandler(-1105);
  972.     
  973.     if not theTarget
  974.         RError("abort_app: Target crashed.", v_level);
  975.     else 
  976.     begin
  977.         currentApp := (_Match([target]).a)[1].t;
  978.         if currentApp = 'Finder'
  979.             return RStatus("abort_app: Can not abort the Finder.",v_level);
  980.         appToAbort := currentApp;
  981.         quitMethod := 1;
  982.         RStatus("abort_app: Attempting to quit '{currentApp}' by any possible method.", v_level);
  983.         
  984.         while appToAbort = currentApp
  985.         begin
  986.             if quitMethod = 1
  987.             begin
  988.                 key_eq('q');
  989.                 quitMethod := 2;
  990.                 RStatus("abort_app: tried command-Q.", v_level);
  991.             end;
  992.             
  993.             else if quitMethod = 2
  994.             begin
  995.                 select_menuItem('Quit');
  996.                 quitMethod := 3;
  997.                 RStatus("abort_app: tried selecting Quit from the File menu.", v_level);
  998.             end;
  999.             
  1000.             else if quitMethod = 3
  1001.             begin
  1002.                 if not unexpected_dialog(,,v_level)
  1003.                     if not close_window()
  1004.                         select_descriptor([button t:"Cancel" e:true]);
  1005.                 quitMethod := 1;
  1006.                 RStatus("abort_app: Tried dismissing the front window/dialog.", v_level);
  1007.             end;
  1008.             
  1009.             await_absence([application t:currentApp],5,,,6);
  1010.             
  1011.             currentApp := (_Match([target]).a)[1].t;
  1012.             RStatus("abort_app: Current app is '{currentApp}'.", v_level);
  1013.         end;
  1014.     end;
  1015. end;
  1016.  
  1017.  
  1018. #########################################################################
  1019. #    task                    quit_all(v_level)
  1020. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1021. #    Description:    Quit all applications, leaving us in the Finder.  First
  1022. #                    check if we are in MultiFinder.  Next, if we are not in
  1023. #                    MultiFinder, check if we are in the Finder already --
  1024. #                    if not, then quit the current application.  If we are in
  1025. #                    MultiFinder, then check if we are in the Finder.  Click
  1026. #                    on the twitch icon. If we aren't in the Finder, then quit
  1027. #                    this app and try again, until we are in the Finder twice
  1028. #                    (before and after clicking on the twitch icon).
  1029. #    Parameters:        v_level:        verbosity level for log output
  1030. #    Returns:        true
  1031. #    Examples:        quit_all();
  1032. #    Assumptions:    None
  1033. #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  1034. #    History:
  1035. #        7/25/90        Alan Liu        Creation as part of FinderLib.vu for 007
  1036. #        3/4/92        Jason Marsh        Incorporated into Clouseau.Lib
  1037. #        09/27/96    BRL/MSO            Added SPEC exception handling
  1038. #########################################################################
  1039. task    quit_all(v_level:=5)
  1040. begin
  1041.     try 
  1042.         match[application t:?oldApp]!;
  1043.     catch theError
  1044.         ExceptionDispatcher(theError,,{"match in quit_all 1", {[application], true}});
  1045.         
  1046.     done := false;
  1047.     while (not done) 
  1048.     begin
  1049.         while (oldApp <> "Finder") 
  1050.         begin
  1051.             if not(abort_app(v_level))
  1052.                 return false;
  1053.             
  1054.             try 
  1055.                 match[application t:?oldApp]!;
  1056.             catch theError
  1057.                 ExceptionDispatcher(theError,,{"match in quit_all 2", {[application], true}});
  1058.         end;
  1059.         twitch();
  1060.  
  1061.         try 
  1062.             match [application t:?newApp]!;
  1063.         catch theError
  1064.             ExceptionDispatcher(theError,,{"match in quit_all 3", {[application], true}});
  1065.  
  1066.         if (newApp = "Finder")
  1067.             done := true;
  1068.         else 
  1069.             oldApp := newApp;
  1070.     end;
  1071.     return true;
  1072. end;
  1073.  
  1074.  
  1075. (*____________________________________________________________________________*)
  1076. #    task hexDecTest(val := 0) begin
  1077. #        if typeOf(val) = 'string' begin    
  1078. #            i := hexStr_to_dec(val);
  1079. #            j := dec_to_hexStr(i);
  1080. #            println "hex value: '{val}'; dec value: {i}; hex value '{j}'";
  1081. #        end;
  1082. #    
  1083. #        else if typeOf(val) = 'integer' begin
  1084. #            i := dec_to_hexStr(val);
  1085. #            j := hexStr_to_dec(i);
  1086. #            println "dec value: {val}; hex value: '{i}'; dec value {j}";
  1087. #        end;
  1088. #    end;
  1089.